#include<vector>
#include<algorithm>

using namespace std;


class Solution {
public:
    int missingNumber(vector<int>& nums) {
        std::sort(nums.begin(), nums.end());
        int left = 0;
        int right = nums.size();

        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] > mid) {
                right = mid;
            }
            else {
                left = mid + 1;
            }
        }

        return left;
    }
};

int main()
{
    Solution s;
    vector<int> v{ 0,2,3};
    s.missingNumber(v);
    return 0;
}